package com.haiyou.dc.message.handler;

import com.haiyou.dc.message.constant.OpenfireConstant;
import lombok.extern.slf4j.Slf4j;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;

/**
 * @author pc
 */
@Slf4j
public class RedisClient implements Runnable {

    private Jedis jedis;

    public RedisClient(Jedis jedis) {
        this.jedis = jedis;
    }

    @Override
    public void run() {
        try {
            JedisPubSub listener = new MessageListener();
            jedis.subscribe(listener, OpenfireConstant.CHANNEL);
        } catch (Exception e) {
            log.error("redis启动订阅监听器失败,e=" + e.getMessage(), e);
        }
    }
}
